package program.commands;

import item.*;

public abstract class BasicCommand  extends Commands {
    /**
     * Initialise this new basic command with a line number.      
     */      
	public BasicCommand(int lineNb) {  
		super(lineNb);         
    } 
	
	/**
	 * Executes this basic command on the given robot.
	 * 
	 * @param       robot     
	 * 		The robot on which the command should be executed.  
	 * @throws      IllegalArgumentException    
	 * 		The given robot should be effective.    
	 * 		| robot == null       
	 * @throws      IllegalArgumentException         
	 * 		The robot should be located on a board.   
	 * 		| robot.getPosition().getBoard() == null          
	 */         
	public void execute(Robot robot) throws IllegalArgumentException {
		if(robot == null)  
			throw new IllegalArgumentException("The given robot should be effective!");    
		if(robot.getPosition().getBoard() == null) 
			throw new IllegalArgumentException("The robot should be located on a board!");   
	}
	
	/**     
	 * Returns this basic command if its line number is larger than the given   
	 * line number, else return null.
	 * @return
	 *| if(getLineNb() > lineNb) 
	 *|       then result == this     
	 *| else if(getLineNb() <= lineNb)       
	 *|       then result == null          
	 */         
	@Override         
	public BasicCommand getNextBasicCommand(int lineNb, Robot robot) {
		if(getLineNb() > lineNb)
		return this;  
	return null;    
	}
}
